﻿using System.Data.Entity.ModelConfiguration;

namespace CS795.TravelAgency.Domain.Entities.Configurations
{
    public class TripConfiguration : EntityTypeConfiguration<Trip>
    {
        public TripConfiguration()
        {
            HasKey(p => p.Id);
            Property(p => p.Name).HasMaxLength(100).IsRequired();
            HasRequired(p => p.User).WithMany().HasForeignKey(p => p.UserId).WillCascadeOnDelete(true);
            HasMany(p => p.CarRentalReservations).WithRequired(p => p.Trip).HasForeignKey(p => p.TripId).WillCascadeOnDelete(true);
            HasMany(p => p.FlightReservations).WithRequired(p => p.Trip).HasForeignKey(p => p.TripId).WillCascadeOnDelete(true);
            HasMany(p => p.HotelReservations).WithRequired(p => p.Trip).HasForeignKey(p => p.TripId).WillCascadeOnDelete(true);
        }
    }
}
